package com.sc.nft.entity.dto;

import cn.hutool.core.convert.Convert;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sc.nft.enums.MarketTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

@Data
@NoArgsConstructor
public class SecondCollectionDTO {
    @ApiModelProperty("id")
    private Long id;
    @ApiModelProperty("藏品Id")
    private Long collectionId;
    @ApiModelProperty("一级标题")
    private String firstTitle;
    @ApiModelProperty("系列Id")
    private Long catenaId;
    @ApiModelProperty("系列名称")
    private String catenaName;
    @ApiModelProperty("藏品名称")
    private String showLevelName;
    @ApiModelProperty("孵化周期")
    private Integer incubationCycle;
    @ApiModelProperty("售出数量")
    private Long salesCount;
    @ApiModelProperty("起始价格")
    private BigDecimal startPrice;
    @ApiModelProperty("当前价格")
    private BigDecimal minPrice;
    @ApiModelProperty("价格区间")
    private String priceRange;
    @ApiModelProperty("防屯收益")
    private BigDecimal preventHoardIncome;
    @ApiModelProperty("增长率")
    private BigDecimal upRatio;
    @ApiModelProperty("手续费")
    private BigDecimal charge;
    @ApiModelProperty("是否上架")
    private Boolean status;
    @ApiModelProperty("分类")
    private MarketTypeEnum marketType;
    @ApiModelProperty("剩余拆配天数")
    private Integer lastDisassemblyDay;
    @ApiModelProperty("自由交易向上百分比")
    private Integer freeUpRatio;
    @ApiModelProperty("自由交易向下百分比")
    private Integer freeDownRatio;
    @ApiModelProperty("浮动价格")
    private BigDecimal floatingPrice;
    @ApiModelProperty("是否开启拆配")
    private Boolean isDisassembly;
    @ApiModelProperty("购买份额")
    private BigDecimal buyShares;
    @ApiModelProperty("拆配配属")
    private BigDecimal disassemblyMultiple;
    @ApiModelProperty("寄售说明")
    private String consignExplanation;
    @ApiModelProperty("最大价格")
    private BigDecimal maxPrice;
    @ApiModelProperty("分润模板Id")
    private String shareProfitPanelName;
    @ApiModelProperty("分润模板Id")
    private Long shareProfitPanelId;


    @ApiModelProperty("是否锁仓")
    private Boolean isLockedPosition;

    @ApiModelProperty("锁仓类型 0:省缺 1:时间模式 2:日期形式 时间模式是获取藏品后延后多久,日期形式是统一锁到对应的时间")
    private Integer lockedPositionType;

    @ApiModelProperty("锁仓市场小时")
    private Integer lockedPositionHour;

    @ApiModelProperty("锁仓到期日期")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lockedPositionTime;

    @ApiModelProperty("是否为平台展示")
    private Boolean platformShow;

    @ApiModelProperty("是否为品牌岛展示")
    private Boolean brandShow;

    @ApiModelProperty("是否为企业展示")
    private Boolean firmShow;

    @ApiModelProperty("排序")
    private Integer sort;

    @ApiModelProperty("gas上链费")
    private String gas;

    @ApiModelProperty("共识区最小值")
    private BigDecimal consensusMinPrice;

    @ApiModelProperty("最大值")
    private BigDecimal consensusMaxPrice;

    @ApiModelProperty("是否开启求购")
    private Boolean enableWantBuy;

    @ApiModelProperty("最低求购价")
    private BigDecimal minWantBuyPrice;

    @ApiModelProperty("最高求购价")
    private BigDecimal maxWantBuyPrice;

    @ApiModelProperty("单次最高求购数量")
    private Integer wantBuyQuantity;

    @ApiModelProperty("求购持有条件")
    private Boolean enableWantBuyHoldCondition;

    @ApiModelProperty("求购消耗道具")
    private Boolean enableWantBuyConsumeProp;

    @ApiModelProperty("求购持有藏品id")
    private Long wantBuyHoldCollectionId;

    @ApiModelProperty("求购持有藏品名称")
    private String wantBuyHoldCollectionName;

    @ApiModelProperty("求购消耗道具id")
    private Long wantBuyConsumePropId;

    @ApiModelProperty("求购消耗道具名称")
    private String wantBuyConsumePropName;

    @ApiModelProperty("求购消耗道具数量")
    private Integer wantBuyConsumePropQuantity;

    public void setGas(BigDecimal gas) {
        this.gas = gas.setScale(2, BigDecimal.ROUND_DOWN).toPlainString();
    }

    public void setUpRatio(BigDecimal upRatio) {
        this.upRatio = upRatio.multiply(Convert.toBigDecimal(100));
    }

    public void setCharge(BigDecimal charge) {
        this.charge = charge.multiply(Convert.toBigDecimal(100));
    }
}
